//某系统的数字密码(大于0),比如1983,采用加密方式进行传输.
//加密规则:先得到每位数,然后每位数都加上5,再对10求余,最后将所有数字反转,得到一串新数
import java.util.Scanner;

public class A15{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		System.out.print("请输入密码:");
		int number = sc.nextInt();
		int temp = number;
		int count = 0;
		while(temp != 0){
			temp = temp / 10;
			count++;
		}
		int[] arr = new int[count];
		int newNumber = 0;
		for(int i = 0;i < arr.length;i++){
			arr[i] = number % 10;
			number = number / 10;
			arr[i] = (arr[i] + 5) % 10;
			newNumber = newNumber * 10 + arr[i];
		}
		System.out.println("加密之后的密码是:" + newNumber);
		//解密  0-9   +5   5-14   %10    5-9,0-4
		int temp1 = newNumber;
		int count1 = 0;
		while(temp1 != 0){
			temp1 = temp1 / 10;
			count1++;
		}
		int[] arr1 = new int[count1];
		int number1 = 0;
		for(int i = 0;i < arr1.length;i++){
			arr1[i] = newNumber % 10;
			newNumber = newNumber / 10;
			if(arr1[i] >= 5 && arr1[i] <= 9){
				arr1[i] = arr1[i] - 5;
			}else{
				arr1[i] = arr1[i] + 10 - 5;
			}
			number1 = number1 * 10 + arr1[i];
		}
		
		System.out.println("解密之后的密码是:" + number1);
		
	}
}